function MM_findObj(n, d) { //v4.01
	var p,i,x;  
	if (!d)
  		d = document; 
	if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
		d = parent.frames[n.substring(p+1)].document; 
		n = n.substring(0,p);
	}
	if (!(x = d[n]) && d.all) 
		x = d.all[n]; 
	for (i = 0; !x && i < d.forms.length; i++)
		x = d.forms[i][n];
	for (i = 0; !x && d.layers && i < d.layers.length; i++)
		x = MM_findObj(n, d.layers[i].document);
	if(!x && d.getElementById)
		x = d.getElementById(n);
	return x;
}

function MM_changeProp(objName, x, theProp, theValue) { //v6.0
	var obj = MM_findObj(objName);
	if (obj && (theProp.indexOf('style.') == -1 || obj.style)) {
		if (theValue == true || theValue == false)
	  		eval('obj.' + theProp + '=' + theValue);
		else 
			eval('obj.' + theProp + '=\"' + theValue + '\"');
  	}
}

function show(item) {
	MM_changeProp(item, '', 'style.display', 'block', 'DIV');
}
function hide(item) {
	MM_changeProp(item, '', 'style.display', 'none', 'DIV');
}

function reply(id) {
	show('rf');
	if (!document.replyform.title.value)
		document.replyform.title.value = title[id];
	if (!document.replyform.body.value)
		document.replyform.body.value = body[id];
}
function reply2() {
	show('rf');
	if (!document.replyform.title.value)
		document.replyform.title.value = pagetitle;
}

function mail(to, subject, contents, cc) {
	show('mf');
	if (to)
		document.mailform.to.value = to;
	if (subject && !document.mailform.subject.value)
		document.mailform.subject.value = subject;
	if (contents && !document.mailform.body.value)
		document.mailform.body.value = contents;
	document.mailform.cc.value = cc ? cc : "";
}
function mail_reply() {
	mail(mail_from, mail_subj_r, mail_content);
}
function mail_reply_all() {
	mail(mail_from, mail_subj_r, mail_content, mail_all);
}
function mail_forward() {
	mail("", mail_subj_f, mail_content, "");
}

function popup(url, w, h) {
	window.open(url, 'mdgpopper', 'width='+w+',height='+h+',title=0,status=0,toolbar=0,directories=0,hotkeys=0,scrolling=1,scrollbars=1,location=0,menubar=0,resizable=1');
}

menu = new Array();
submenus = new Array();
menulock = new Array();
hasnew = new Array();
info = new Array();

function menu_swap(id) {
	if (menulock[id]) {
		hide('submenu_'+id);
		hide('submenu_open_'+id);
		MM_changeProp('submenu_close_'+id, '', 'style.display', 'inline', 'DIV');
	} else {
		MM_changeProp('submenu_'+id, '', 'style.display', 'inline', 'DIV');
		//show('submenu_'+id);
		MM_changeProp('submenu_open_'+id, '', 'style.display', 'inline', 'DIV');
		hide('submenu_close_'+id);
	}
	menulock[id] = 1-menulock[id];
}
function menu_info(id) {
	MM_changeProp('infopane', '', 'innerHTML', info[id], 'DIV');
}
function menu_info_restore() {
	MM_changeProp('infopane', '', 'innerHTML', old_info, 'DIV');
}
function menu_hi(id) {
	MM_changeProp('menu_'+id+'_'+id, '', 'style.backgroundColor', color_hi, 'DIV');
}
function submenu_hi(menu, id) {
	menu_info(id);
	MM_changeProp('submenu_'+menu+'_'+id, '', 'style.backgroundColor', color_hi, 'DIV');
}
function menu_lo(id) {
	setTimeout('really_menu_lo('+id+')', 2000);
	menu_info_restore();
}
function really_menu_lo(id) {
	MM_changeProp('menu_'+id+'_'+id, '', 'style.backgroundColor', color_lo, 'DIV');
}
function submenu_lo(menu, id) {
	MM_changeProp('submenu_'+menu+'_'+id, '', 'style.backgroundColor', color_lo, 'DIV');
	menu_info_restore();
}

function forum_hi(id) {
	MM_changeProp('forum_'+id, '', 'style.backgroundColor', color_hi, 'DIV');
}
function forum_lo(id) {
	MM_changeProp('forum_'+id, '', 'style.backgroundColor', color_lo, 'DIV');
}

function item_hi(id) {
	MM_changeProp('item_'+id, '', 'style.backgroundColor', color_hi, 'DIV');
}
function item_lo(id) {
	MM_changeProp('item_'+id, '', 'style.backgroundColor', color_lo, 'DIV');
}

function mail_hi(id) {
	MM_changeProp('mail_'+id, '', 'style.backgroundColor', color_hi, 'DIV');
}
function mail_lo(id) {
	MM_changeProp('mail_'+id, '', 'style.backgroundColor', color_lo, 'DIV');
}

function showsubs(id) {
	show('hiddensub_' + id);
	show('subhider_' + id);
	hide('subshower_' + id);
	//MM_changeProp('items_' + id, '', 'style.borderBottomWidth', '0px', 'DIV');
	location.href = '#sub' + id;
}
function hidesubs(id) {
	hide('hiddensub_' + id);
	hide('subhider_' + id);
	show('subshower_' + id);
	//MM_changeProp('items_' + id, '', 'style.borderBottomWidth', '1px', 'DIV');
	location.href = '#sub' + id;
}

function addCode(t, mode, code1, code2) {
	t.focus();
	if (document.selection && document.selection.createRange) {
		if (mode == "REPLACE") {
			t.focus();
			document.selection.createRange().text = code1;
		} else {
			var str = code1 + document.selection.createRange().text + code2;
			t.focus();
			document.selection.createRange().text = str;
		}
	} else {
		var before = t.value.substring(0, t.selectionStart);
		var after = t.value.substring(t.selectionEnd);
		if (mode == "REPLACE") {
			t.value = before + code1 + after;
		} else {
			var selected = t.value.substring(t.selectionStart, t.selectionEnd);
			t.value = before + code1 + selected + code2 + after;
		}
	}
	t.focus();
}
function replace(target, code) {
	addCode(target, "REPLACE", code);
}
function surround(target, heads, tails) {
	addCode(target, "SURROUND", heads, tails);
}